package br.com.ep.generico.util;

import java.lang.reflect.Field;

public class ReflectionUtil {
	
	@SuppressWarnings("rawtypes")
	public static Field getField(Class clazz, String atribute) {			
		while (clazz != null) {
			try {
				return clazz.getDeclaredField(atribute);
			} catch (SecurityException e) {
				return null;
			} catch (NoSuchFieldException e) {
				clazz = clazz.getSuperclass();
			}
		}
		return null;
	}
	
	public static Field getField(Object instance, String atribute) {
		return getField(instance.getClass(), atribute);
	}
	
	
//	//method call by reflection
//
//	Class[] args1 = new Class[1];
//	args1[0] = String.class;
//
//	findMethod = className.getDeclaredMethod("find", args1);
//
//	List enuns = (List) findMethod.invoke(className, new Object[] { searchParameter.getInitialValue() });
//	
}
